<?php
/**
 * Created by PhpStorm.
 * User: waw
 * Date: 2019/6/20
 * Time: 14:20
 */
//得到当前登录者的信息  页面传值  session动态页面(asp php ..)之间传值
//浏览器到服务器是通过cookie传值
//取值 (是一个数组结构) 存值在loginphp     login登录存值
//浏览器关闭  首先消灭cookie


session_start();

if(!isset($_SESSION["registor"])){
    $result=array("msg"=>"请先登录","status"=>2);
    print_r(json_encode($result));
    return;
}
$userID=json_decode(json_encode($_SESSION["registor"]))->u_name;
include "./DBhelper.php";
//准备sql语句  查询 1 修改  插入   返回结果
//$querySQlL="SELECT *FROM `cartslist`where uid="
$querySQL="SELECT *FROM `cartlists` WHERE uid='".$userID."'";
$resultData= sqlQuery($querySQL);
$resultJSON=array("msg"=>"查询失败","status"=>3);
if($resultData->num_rows>=1){
    $resultJSON["msg"]="finished";
    $resultJSON["status"]=1;

    $data=array();
//    因为fetch_assoc()每次只能读取一条
    while($row=$resultData->fetch_assoc()){
        array_push($data,$row);
    }
    $resultJSON["data"]=$data;
}
print_r(json_encode($resultJSON));



